﻿#region Imports

using System;
using System.Collections;
using System.Security.Cryptography;
using System.Text;

using Workflow.IService;
using Workflow.IDAO;
using Workflow.Model;

#endregion

namespace Workflow.Service
{
    public class DepartmentManager:IDepartmentManager
    {
        #region Properties

        public IDepartmentDao DepartmentDao { get; set; }

        #endregion

        public Department SaveDepartment(Department Department)
        {
			DepartmentDao.Save(Department);
			return Department;
        }

        public void DeleteDepartment(string comapnyID)
        {
            Department Department = GetDepartment(comapnyID);
            if (Department != null)
            {
                DepartmentDao.Delete(Department);
            }
            else
            {
                throw new Exception("不存在的公司");
            }
        }

        public Department UpdateDepartment(Department Department)
        {
        	DepartmentDao.SaveOrUpdate(Department);
            return Department;
        }

        public Department GetDepartment(string DepartmentID)
        {
            return DepartmentDao.Get(DepartmentID);
        }

        public Department NewDepartment()
        {
            return new Department();
        }


        public IList GetAll()
        {
            return (IList) DepartmentDao.LoadAll();
        }

    }
}
